package org.cytoscape.myapp.cytoscape_app_v1.internal.helpers;

import java.util.Collection;

import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.group.CyGroup;
import org.cytoscape.group.events.GroupAboutToBeDestroyedEvent;
import org.cytoscape.group.events.GroupAboutToBeDestroyedListener;
import org.cytoscape.group.events.GroupAboutToBeRemovedEvent;
import org.cytoscape.group.events.GroupAboutToBeRemovedListener;
import org.cytoscape.group.events.GroupAboutToCollapseEvent;
import org.cytoscape.group.events.GroupAboutToCollapseListener;
import org.cytoscape.group.events.GroupAddedEvent;
import org.cytoscape.group.events.GroupAddedListener;
import org.cytoscape.group.events.GroupCollapsedEvent;
import org.cytoscape.group.events.GroupCollapsedListener;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
import org.cytoscape.model.events.AddedNodesEvent;
import org.cytoscape.model.events.AddedNodesListener;
import org.cytoscape.model.events.RemovedNodesEvent;
import org.cytoscape.model.events.RemovedNodesListener;
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.view.model.CyNetworkViewManager;
import org.cytoscape.view.model.View;
import org.cytoscape.view.model.events.AboutToRemoveNodeViewsEvent;
import org.cytoscape.view.model.events.AboutToRemoveNodeViewsListener;
import org.cytoscape.view.presentation.property.BasicVisualLexicon;

public class ViewUtil implements GroupAboutToCollapseListener, AboutToRemoveNodeViewsListener, GroupAboutToBeDestroyedListener{
	
	private CyApplicationManager applicationManager;
	private CyNetworkViewManager networkViewManager;

	public ViewUtil(CyApplicationManager applicationManager2,
			CyNetworkViewManager networkViewManager2) {
		
		applicationManager = applicationManager2;
		networkViewManager = networkViewManager2;
	}

	/*public void UpdateView(CyNetwork network){
		Collection<CyNetworkView> views = networkViewManager.getNetworkViews(network);
		for(CyNetworkView view:views)
			view.updateView();
		System.out.println("actualizo vista");
	}*/

	@Override
	public void handleEvent(GroupAboutToCollapseEvent e) {
	/*	if (e.collapsing())
			System.out.println("colapando");
			e.getSource().collapse(applicationManager.getCurrentNetwork());
		else{
			System.out.println("expandiendo");
			//e.getSource().getGroupNode();
			//applicationManager.getCurrentNetworkView().getNodeView(e.getSource().getGroupNode()).setVisualProperty(BasicVisualLexicon.NODE_VISIBLE, false);
			//e.getSource().expand(applicationManager.getCurrentNetwork());
		}
		//this.UpdateView(e.getNetwork());*/
	}

	@Override
	public void handleEvent(AboutToRemoveNodeViewsEvent e) {
/*
		System.out.println("Se elimino nodo de vista");
		e.getSource().updateView();*/
		
	}

	@Override
	public void handleEvent(GroupAboutToBeDestroyedEvent e) {
	 /*
		System.out.println("Se elimino grupo");
		applicationManager.getCurrentNetworkView().updateView();*/
		
	}
	
}
